package com.sunxu.definition;

import com.sunxu.ioc.domain.User;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;

/**
 * @author 孙许
 * @version 1.0
 * @date 2020/6/13 21:15
 * 注解BeanDefinition
 */
public class AnnotationBeanDefinitionDemo {

    public static void main(String[] args) {
        AnnotationConfigApplicationContext applicationContext = new AnnotationConfigApplicationContext();
        applicationContext.register(Config.class);
        applicationContext.close();
    }

    public static class Config {
        @Bean
        public User user() {
            User user = new User();
            user.setId(1L);
            user.setName("孙许");
            return user;
        }
    }
}
